package com.example.edu.app;

import android.app.Activity;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.StrictMode;
import android.provider.Settings.Secure;
import android.util.Log;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.edu.connection.connection;


public class UserDB 
{
 public String KEY_USERNAME = "Username";
 public  String KEY_PASSWORD = "Password";
 public String KEY_LNAME = "LastName";
 public String KEY_FNAME = "FirstName";

 private static final String DATABASE_NAME = "Users";
 private static final String DATABASE_TABLE = "User";

 private static final int DATABASE_VERSION = 1;

 private static Context context;

 
 private static SQLiteDatabase db;

 public UserDB(Context ctx)
 {
  this.context = ctx;
  DBHelper = new DatabaseHelper(context);
 }



  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
  {
  }

  @Override
  public void onCreate(SQLiteDatabase db)
  {
  }
 }//end DatabaseHelper

 // ---opens the database---
 public UserDB open() throws SQLException
 {
  db = DBHelper.getWritableDatabase();
  return this;
 }

 // ---closes the database---
 public void close()
 {
  DBHelper.close();
 }


}

public class Register extends Activity implements OnClickListener {

	
	@Override
	 public boolean onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
		 
		 StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
		 StrictMode.setThreadPolicy(policy); 
		 
		 String android_id = Secure.getString(getBaseContext().getContentResolver(),Secure.ANDROID_ID); 
		 
		 Log.d("Device Id", android_id);
		 
		 setContentView(R.layout.registration);
		 
		 Button b=(Button)findViewById(R.id.button1);
		 b.setOnClickListener(this);
		 
		 if(connection.isUserConnectedBefore(android_id))
			 goToMainScreen(findViewById(R.id.login));
		 return true;
	 }
	// 



}


		 
	